<template>
    <Modal v-model="perfectCompanyInfoModal" width="650" class="col-2" :closable="false" :mask-closable="false">
        <div slot="header">
            核注清单导入/申报时请补全以下信息
            <Icon class="f-fr" type="ios-close" @click="cancel"/>
        </div>
        <Form :model="companyForm" ref="companyIcRef" label-position="right" :rules="rules" :label-width="160" inline>
            <Row>
                <iCol span="24">
                    <FormItem label="单一窗口客户端ID：" prop="clientId" class="clientId">
                        <Input v-model="companyForm.clientId"></Input>
                    </FormItem>
                </iCol>
            </Row>
        </Form>
        <div slot="footer">
            <div slot="footer">
                <Button type="primary" @click="save">确定</Button>
                <Button type="default" @click="cancel">取消</Button>
            </div>
        </div>
    </Modal>
</template>

<script>
import { httpPost } from '@/libs/http'

export default {
    name: 'PerfectCompanyInfoModal',
    data () {
        return {
            perfectCompanyInfoModal: false,
            companyForm: {
                clientId: ''
            },

            rules: {
                clientId: [
                    { required: true, message: '单一窗口客户端ID', trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
        init () {
            this.perfectCompanyInfoModal = true
            this.$nextTick(() => {
                this.$refs['companyIcRef'].resetFields()
            })
        },

        save () {
            this.$refs['companyIcRef'].validate((valid) => {
                if (!valid) {
                    return false
                }
                httpPost('/customs/sys/saveDecInfo', this.companyForm).then(res => {
                    if (res.code === '0000') {
                        this.$Message.success('保存成功,请继续导入或申报')
                        this.cancel()
                    }
                })
            })
        },

        cancel () {
            this.perfectCompanyInfoModal = false
            this.$emit('perfectCompanyInfoAfter')
        }
    }
}
</script>

<style scoped>

</style>
